#!/bin/bash

# 创建网站目录（根据您的操作系统调整路径）
mkdir -p ~/upme/frontend
mkdir -p ~/upme/backend

# 复制前端文件
cp -r ../frontend/* ~/upme/frontend/

# 安装后端依赖
cd ../backend
pip3 install -r requirements.txt

# 复制后端文件
cp -r * ~/upme/backend/

# 配置Nginx（路径可能需要根据操作系统调整）
if [[ "$OSTYPE" == "darwin"* ]]; then
    # MacOS
    sudo cp nginx.conf /usr/local/etc/nginx/servers/upme.cool.conf
    sudo nginx -s reload
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
    # Linux
    sudo cp nginx.conf /etc/nginx/sites-available/upme.cool
    sudo ln -s /etc/nginx/sites-available/upme.cool /etc/nginx/sites-enabled/
    sudo nginx -t
    sudo systemctl restart nginx
fi

# 启动后端服务
cd ~/upme/backend
python3 chat_api.py &

echo "本地部署完成！"
echo "请确保已经配置了DDNS服务和路由器端口转发"
echo "访问 http://localhost 测试网站" 